package com.bulletelc.apollopre.module.main.center.quotation;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bulletelc.apollopre.R;
import com.bulletelc.apollopre.entity.QuotationBean;

import java.util.List;

/**
 * Created by Administrator on 2018/5/17.
 */

public class QuotationListAdapter extends BaseAdapter {

    private Context context;
    private List<QuotationBean> quotationBeanList;
    private LayoutInflater inflater;

    public QuotationListAdapter(Context context, List<QuotationBean> list) {
        this.context = context;
        this.quotationBeanList = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return quotationBeanList.size();
    }

    @Override
    public Object getItem(int i) {
        return quotationBeanList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        QuotationBean qb = quotationBeanList.get(i);
        ViewHolder viewHolder;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = inflater.inflate(R.layout.quotation_list_item, viewGroup, false);
            viewHolder.tvOrder = view.findViewById(R.id.tvOrder);
            viewHolder.tvTotal = view.findViewById(R.id.tvTotal);
            viewHolder.tvDate = view.findViewById(R.id.tvDate);
            viewHolder.tvState = view.findViewById(R.id.tvState);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.tvOrder.setText(context.getString(R.string.intention_order) + qb.getCode());
        viewHolder.tvTotal.setText("¥" + String.valueOf(qb.getGrand_total()));
        viewHolder.tvDate.setText(context.getString(R.string.quotation_date) + qb.getOccurrence_date());
        return view;
    }

    class ViewHolder {
        TextView tvOrder, tvTotal, tvDate, tvState;
    }

}
